from flask import Flask
from cfg import Config
from utils import FILTERS

from .exts import init_exts
from .blog import models
from .admin import models

from .view import roots_bp
from .blog.views import blog_bp
from .admin.views import admin_bp


def create_app():
    app = Flask(__name__, static_folder='../static', template_folder='../templates')
    app.config.from_object(Config)
    for key, value in FILTERS.items():
        app.add_template_filter(value, key)
    init_exts(app)

    app.register_blueprint(roots_bp)
    app.register_blueprint(blog_bp)
    app.register_blueprint(admin_bp)
    return app
